program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var s,pr,pf : string;

function calc(l : integer) : integer;
var a : int64; i,cl : integer; p : boolean;
begin
  calc := length(pf)+1;
  a := 0;
  cl := 0;
  p := false;
  for i := 1 to length(pr) do
    if (pr[i] <> '+') and (pr[i] <> '*') and (pr[i] <> '?') then
      inc(cl)
    else
      if pr[i] = '?' then cl := l
      else begin
        if p then a := (a)*(cl+1) else a := a+cl;
        if a > length(pf) then exit;
        cl := 0;
        p := pr[i] = '*';
      end;
  if p then a := (a)*(cl+1) else a := a+cl;
  if a > length(pf) then exit;
  calc := a;
end;

var n,m,i,j,l,r : integer; cm : int64; cl : integer;

begin
  readln(s);
  pr := copy(s,1,pos('=',s)-1);
  pf := copy(s, pos('=',s)+1, length(s));
  l := 1;
  r := length(pf);
  calc(2);
  while (l <> r) do
    begin
      m := (l+r) div 2;
      cm := calc(m);
      if cm = length(pf) then
        break
      else
        if cm < length(pf) then
          l := m+1
        else
          r := m-1;
    end;
  m := (l+r) div 2;
  i := length(pr);
  cl := 0;
  while pr[i] <> '?' do
    begin
      if (pr[i] <> '+') and (pr[i] <> '*') and (pr[i] <> '?') then inc(cl) else
        begin
          if (pr[i] = '+') then delete(pf, length(pf)-cl+1,cl) else
            begin
               s := '';
               j := 1;
               while (j <= length(pf)) do
                begin
                  s := s + pf[j];
                  j := j + cl + 1;
                end;
               pf := s;
            end;
          cl := 0;
        end;
      dec(i);
    end;
  writeln(copy(pf, length(pf)-m+1,m));
end.
                   